<!doctype html>
<html>
<head>
    <meta http-equiv="content-type" content="text/html; charset=UTF-8"/>
    <title>帮教资料页面</title>
    <script src="/webjars/miniui/boot.js" type="text/javascript"></script>
    <link href="/static/css/resource.css" rel="stylesheet" type="text/css"/>
    <script src="/static/js/common/common.js" type="text/javascript"></script>
    <link href="/webjars/miniui/css/demo.css" rel="stylesheet" type="text/css"/>
    <link href="/static/css/default.css" rel="stylesheet" type="text/css"/>
    <style>
        .discell{
            text-align: right;
            width: 300px;
        }

        .input{
            width: 400px;
        }
    </style>
</head>
<body>
<div class="mini-fit" style="margin-bottom: 40px;">
<form id="form1" method="post" style="height:100%;width: 100%;overflow-x: auto;overflow-y: auto;" >
    <!-- 编辑框START-->
    <div id="editform" class="form" style="padding:10px;margin-left: -30%">
        <input id="id" name="id" class="mini-hidden" style="width: 100%;"  value="${id!''}"/>
        <input id="adduserid" name="adduserid" class="mini-hidden"  style="width: 100%;" value="${adduserid!''}"/>
        <input id="updanwei" name="updanwei" class="mini-hidden"  style="width: 100%;" value="${updanwei!''}"/>
        <input name="createUser" class="mini-hidden"  style="width: 100%;" value="${createUser!''}"/>
        <input name="ischeck" class="mini-hidden"  style="width: 100%;" value="${ischeck!''}"/>
        <table class="form-table" align="center" cellspacing="8">
            <tr>
                <td class="discell"><font color="#dc143c">*</font>资料名称:</td>
                <td >
                    <input name="zlmc" id="zlmc" class="mini-textbox" style="width: 470px" required="true"/>
                </td>
            </tr>
            <tr>
                <td class="discell"><font color="#dc143c">*</font>资料类型:</td>
                <td>
                    <input name="type"  id="type" class="mini-combobox" style="width: 470px" required="true"
                           textField="codeName" valueField="codeId" emptyText="请选择..."
                           url="/azbj/shzzgl/socialOrgInfo/getComboboxData?codeType=3_5"
                    />
                </td>
            </tr>
            <tr>
                <td class="discell"><font color="#dc143c">*</font>发布范围:</td>
                <#if userlevel=='07'>
                    <td class="input">
                        <input name="usertype" id="usertype" class="mini-checkboxlist" required="true"
                               textField="name" valueField="id" emptyText="请选择..." onvaluechanged = "changeXjyh()"
                               data="[{ id: 07, name: '地市司法局' },{ id: 08, name: '区县司法局' },
                                       { id: 03, name: '基层司法所' }<#--,{ id: 01, name: '监所' }-->]"/>
                    </td>
                <#elseif userlevel=='08'>
                    <td class="input">
                        <input name="usertype" id="usertype" class="mini-checkboxlist" required="true"
                               textField="name" valueField="id" emptyText="请选择..." onvaluechanged = "changeXjyh()"
                               data="[{ id: 08, name: '区县司法局' },{ id: 03, name: '基层司法所' }<#--,{ id: 01, name: '监所' }-->]"/>
                    </td>
                <#elseif userlevel=='09'>
                    <td class="input">
                        <input name="usertype" id="usertype" class="mini-checkboxlist" required="true"
                               textField="name" valueField="id" emptyText="请选择..." onvaluechanged = "changeXjyh()"
                               data="[{ id: 09, name: '监狱局' },{ id: 01, name: '监所' }]"/>
                    </td>
                <#elseif userlevel=='06'>
                    <td class="input">
                        <input name="usertype" id="usertype" class="mini-checkboxlist" required="true"
                               textField="name" valueField="id" emptyText="请选择..." onvaluechanged = "changeXjyh()"
                               data="[{ id: 06, name: '省司法厅' },{ id: 07, name: '地市司法局' },
                               { id: 08, name: '区县司法局' },{ id: 03, name: '基层司法所' },
                               { id: 09, name: '监狱局' },{ id: 01, name: '监所' }]"/>
                    </td>
                <#else>
                    <td class="input">
                        <input name="usertype" id="usertype" class="mini-checkboxlist" required="true"
                               textField="name" valueField="id" emptyText="请选择..." onvaluechanged = "changeXjyh()"
                               data="[{ id: 06, name: '省司法厅' },{ id: 07, name: '地市司法局' },
                               { id: 08, name: '区县司法局' },{ id: 03, name: '基层司法所' },
                               { id: 01, name: '监所' }]"/>
                    </td>
                </#if>
            </tr>
            <tr id="upload">
                <td  class="discell">附件下载:</td>
                <td>
                    <input type="button" onclick="onFileUpload()" value="查看附件" style="width: 112px"/>
                </td>
            </tr>
        </table>
    </div>
    <!--编辑框END-->
</form>
</div>

<div id="bottombuttton" style="width:100%; position: absolute;bottom: 0;line-height: 40px;border-top: 1px solid #dfdfdf;text-align: center;">
    <a class="mini-button" iconCls="fa-save" plain="true" onclick="saveData()">保存</a>
    <a class="mini-button" iconCls="fa-undo" plain="true" onclick="onCancel()">取消</a>
</div>

<script type="text/javascript">
    mini.parse();
    var form = new mini.Form("form1");
    var adduserid = mini.getByName("adduserid").getValue();
    var updanwei = mini.getByName("updanwei").getValue();
    var createUser = mini.getByName("createUser").getValue();
    var ischeck = mini.getByName("ischeck").getValue();
    //标准方法接口定义
    function SetData(data) {
        var o = mini.decode(data);
        form.setData(o);
        form.setChanged(false);
        form.setEnabled(false);
        //编辑时设置id
        mini.get("id").setValue(data.id);
        //将保存取消按钮隐藏
        document.getElementById("bottombuttton").style.display = "none";
    }

    function saveData() {
        //验证非空字段
        form.validate();
        if (form.isValid() == false) {
            return;
        }
        var data = form.getData();
        //处理id
        var id = mini.get("id").getValue();
        if(!id){
            id=${id!''};
        }
        data.id=id;
        data.adduserid=adduserid;
        data.updanwei=updanwei;
        data.createUser=createUser;
        var json = mini.encode(data);
        commonSaveData("/azbj/abzlxxgl/azbjDatabaseInfo/save", {data: json}, callback);
        // 保存成功的回调函数
        function callback() {
            mini.alert("保存成功","成功",window.CloseOwnerWindow);
        }
    }

    // 上传附件 taskId=26 代表帮教资料
    function onFileUpload() {
        var id = mini.get("id").getValue();
        if(!id){
            id=${id!''};
        }
        commonEdit("/upload/user/uploadAppendixfile/see?1=1&id="+id+"&priNum="+id+"&taskId=26", "", null, "40%", "40%",true,true,true);
    }
</script>
</body>
</html>